<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Using the command line compiler</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="5">Using the command line compiler</font></b></p>


<p><b>Introduction</b></p><blockquote>





The command line compiler is located in the subdirectory 'Compilers\' from the PureBasic folder. 
The easier way to access this is to add this directory in the windows PATH variable, 
which will give access to all the commands of this directory at all times. 

 

</blockquote>
<p><b>Command switches</b></p><blockquote>





/? : display a quick help about the compiler. <br>
<br>
/COMMENTED : create a commented '.asm' output file when creating an executable. 
This file can be re-assembled later when the needed modifications have been made. 
This option is for advanced programmers only. <br>
<br>
/DEBUGGER : enable the debugger support. <br>
<br>
/EXE "Filename" : create a standalone Executable or DLL specified by the filename at the desired path location. <br>
<br>
/ICON "IconName.ico" : add the specified icon to the executable. <br>
<br>
/RESIDENT "Filename" : create a resident file specified by the filename. <br>
<br>
/CONSOLE: output file in <a href="../console/index.html">Console</a> format. Default format is Win32. <br>
<br>
/DLL: output file is a <a href="../reference/dll.html">DLL</a>. <br>
<br>
/XP: Add the Windows XP theme support to the executable. <br>
<br>
/REASM: Reassemble the PureBasic.asm file into an executable. This allow to use the /COMMENTED function, 
modify the ASM output and creates the executable again. <br>
<br>
/LINENUMBERING: Add lines and files information to the executable, which can slow it considerably. 
This allows the <a href="../onerror/index.html">OnError library</a> to report the file and line-number of an error. <br>
<br>
/QUIET: Disable all unnecessary text output, very useful when using another editor. <br>
<br>
/STANDBY: Loads the compiler in memory and wait for external commands (editor, scripts...). 
More information about using this flag is available in the file 'CompilerInterface.txt' from the PureBasic 'SDK' directory. <br>
<br>
/MMX, /3DNOW, /SSE or /SSE2: Creates a processor specific executable. This means if a 
processor specific routine is available it will be used for this executable. 
Therefore, the executable will run correctly only on computer with this kind of CPU. <br>
<br>
/DYNAMICCPU: Creates a executable containing all the available processor specific routines. 
When the program is started, it looks for the processor type and then select the more 
appropriates routines to use. This makes a bigger executable, but result in the 
fastest possible program.<br>
<br>
/RESOURCE "Filename": Add a Windows resource file (.rc) to the created executable or DLL. This 
should be not a compiled resource file, but an ascii file with the directives in it. It's possible 
to specify only one resource, but this file can include other resource script if needed. <br>
<br>
/LINKER "ResponseFile": Specify a file which contains commands to be passed directly to the linker. 
On Windows, PureBasic use the PellesC linker (polink), more information about the possible 
options can be found in the related documentation. <br>
<br>
/IGNORERESIDENT "Filename": Doesn't load the specified resident file when the compiler starts. It's 
mostly useful when updating a resident which already exists, so it won't load it. <br>
<br>
/CONSTANT Name=Value: Creates the specified constant with the given expression. 
Example: 'pbcompiler test.pb /CONSTANT MyConstant=10'. The constant <font color="#924B72">#MyConstant</font> 
will be created on the fly with a value of 10 before the program gets compiled. <br>
<br>
/UNICODE: Use unicode instead ascii for strings management.<br>
<br>
/THREAD: Use thread safe runtime for strings and general routines.<br>
<br>
/SUBSYSTEM "Name": Uses the specific subsystem to replace a set of internal functions. For 
more information, see <a href="../reference/subsystems.html">subsystems</a>. 
<br>
<br>
The following two compiler options are needed for creating programs running on Microsoft Vista OS. 
They are both options for the included manifest, so they are ignored on older windows versions. 
With none of these switches, the exe will run as a normal user as well, but with virtualization 
turned on (i.e. registry and file redirection). It is recommended to use the /USER switch to turn 
of virtualization for all programs that comply to the standard user privileges, as it is only 
intended for compatibility for older programs. These options are also available in the 
<a href="../reference/ide_compiler.html">IDE compiler options</a>. 
<br>
/ADMINISTRATOR: Will cause the program to request admin privileges at start. The program 
will not run without it. This option is needed. Note: You can also <a href="../reference/ide_debugger.html">debug</a> 
programs with this flag, but only with the standalone gui debugger (as it must run in elevated mode as well). 
<br>
/USER: The program will run as the user who started it. Virtualization for the exe is turned off. 
<br>
/CHECK: Check the syntax only, doesn't create or launch the executable. 
<br>
/PREPROCESS "Filename": Preprocess the source code and write the output in the specified "Filename". 
The processed file is a single file with all macro expanded, compiler directive handled and 
multiline resolved. This allows an easier parsing of a PureBasic source file, as all is expanded 
and is available in a flat file format. No comments are included by default, but the flag /COMMENTED can be 
used to have all untouched original source as comments and allow comments processing. The preprocessed 
file can be recompiled as any other PureBasic source file to create the final executable. 
<br>
/VERSION: Displays the compiler version. 
<br>

<p><b>Example</b></p><blockquote>


<pre><font face="Courier New, Courier, mono"size="2">  CLI&gt; pbcompiler sourcecode.pb
</font></pre>



The compiler will compile the source code and execute it.  <br>
<br>

<pre><font face="Courier New, Courier, mono"size="2">  CLI&gt; pbcompiler sourcecode.pb /DEBUGGER
</font></pre>



The compiler will compile the source code and execute it with debugger. 

 

<pre><font face="Courier New, Courier, mono"size="2">  CLI&gt; pbcompiler "C:\Project\Source\DLLSource.pb" /EXE "C:\Project\project.dll" /DLL
</font></pre>



The compiler will compile the source code (here with full path) and create the DLL "project.dll" in the given directory. 




 




</body></html>